#@adminLayout()
#define main()
<main class="app-content">
<div class="app-title">
	<div>
		<h1><i class="fa fa-edit"></i>用户权限分配</h1>
		<p>点亮左侧开关分配角色，同一账号可分配多个角色</p>
	</div>
      <ul class="app-breadcrumb breadcrumb">
        <li class="breadcrumb-item"><a href="/admin"><i class="fa fa-home fa-lg"></i>仪表盘</a></li>
        <li class="breadcrumb-item active"><a href="/admin/user">用户管理</a></li>
        <li class="breadcrumb-item active"><a href="javascript:;">权限分配</a></li>
      </ul>
</div>
<div class="row">
	<div class="col-md-12">
		<div class="tile">
			<div class="row">
				<div class="col-lg-8">
				<h3 class="tile-title">正在给<font style="color: red;">#(user.nickName)</font>分配权限</h3>
				<table class="table table-striped">
	              <tbody>
	              #for(x : roleList)
					<tr>
						<td>
							<div class="toggle lg"><label>
								<input type="checkbox" data-account-id="#(user.uid)" data-role-id="#(x.id)" 
								#if(x.assigned) checked #end
								class="mgc-switch mgc-tiny" ><span class="button-indecator"></span>
							</label></div>

						</td>
						<td>#(x.name)</td>
					</tr>
					#end
	              </tbody>
	            </table>
				</div>
			</div>
		</div>
	</div>
</div>
</main>
#end
#define js()
<script type="text/javascript">
	$(document).ready(function() {
		initMagicInput(prepareAction);
	});

	function prepareAction($this, state) {
		return {
			url: state ? "/admin/user/addRole" : "/admin/user/deleteRole",
			data : {
				accountId: $this.data("account-id"),
				roleId: $this.data("role-id")
			}
		}
	}
</script>
#end